#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"mypushbutton.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    pb1=new QPushButton(this);
    pb1->setText("命令按钮1");

    pb1->setGeometry(0,50,100,100);
    pb2=new QPushButton(this);
    pb2->setText("命令按钮2");
    pb2->setGeometry(100,50,100,100);

    connect(pb1,&QPushButton::clicked,this,&MainWindow::btn1_clicked);
    connect(pb2,&QPushButton::clicked,this,&MainWindow::btn2_clicked);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::btn1_clicked()
{
    this->setStyleSheet("MainWindow {background-color:rgb(255,255,255);}");
}

void MainWindow::btn2_clicked()
{
    this->setStyleSheet("MainWindow {background-color:rgb(0,0,255);}");
}

